{{--
/**
 * Created by PhpStrom
 * User: 郭碧云
 * Date: 2021/7/12 14:38
 * Desc:
 */--}}
<style>
    .layui-treeSelect {
        width: 80% !important;
    }
</style>
<form id="question_type_from" style="margin-top: 15px;" action="{{route('admin.questionType.create')}}"
      class="layui-form">
    {{csrf_field()}}
    <div class="layui-form-item">
        <label class="layui-form-label">名称</label>
        <div class="layui-input-block">
            <input type="text" id="name" name="data[name]" autocomplete="off" placeholder="名称" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">分类</label>
        <div class="layui-input-block">
            <select id="type" name="data[type]" lay-filter="change">
                <option value="0">--请选择--</option>
                {!! Code::getOptionsByCode('QUESTION_TYPE') !!}
            </select>
        </div>
    </div>


    <div class="layui-form-item" id="choice_box">
        <label class="layui-form-label">选项分类</label>
        <div class="layui-input-block">
            <select id="choice_type" name="data[choice_type]">
                <option value="0">--请选择--</option>
                {!! Code::getOptionsByCode('CHOICE_TYPE') !!}
            </select>
        </div>
    </div>

</form>

<script>
    layui.use(['form', 'jquery'], function () {
        let form = layui.form,
            $=layui.jquery;
        form.on('select(change)',function (){
            if($("#type").val()!=1){
                $("#choice_box").hide();
                $("#choice_box").val(0);
            }else{
                $("#choice_box").show();
            }
        })
    })
</script>
